import { RouteRecordRaw } from "vue-router";
import Index from "@/views/layout/index.vue";
import permession from "./permession";

/**
 * staticRouter (静态路由)
 */
export const staticRouter = [
    {
        path: "/",
        name: "home",
        redirect: "/home",
        component: Index,
        meta: {
            cache: false,
            hide: true,
        },
        children: [
            {
                path: "/home",
                name: "home",
                meta: {
                    title: "首页",
                    hide: true,
                    icon: "home",
                },
                component: () => import("@/views/dashbroad/Index.vue"),
            },
        ],
    },
    {
        path: "/login",
        name: "login",
        meta: {
            title: "",
            hide: true,
            auth: true,
        },
        component: () => import("@/views/login/Index.vue"),
    }
]

/**
 * errorRouter (错误页面路由)
 */
export const errorRouter = [
    {
        path: "/401",
        name: "error_401",
        meta: {
            hide: true,
        },
        component: () => import("@/views/errors/401.vue"),
    },
    {
        path: "/404",
        name: "error_404",
        meta: {
            hide: true,
        },
        component: () => import("@/views/errors/404.vue"),
    },
    {
        path: "/500",
        name: "error_500",
        meta: {
            hide: true,
        },
        component: () => import("@/views/errors/500.vue"),
    },
    {
        path: '/:pathMatch(.*)*',
        name: 'NotFound',
        component: () => import("@/views/errors/404.vue")
    }
]

/**
 * 公共路由 (静态路由 + 错误页面路由)
 */
export const publicRouter: Array<RouteRecordRaw> = [
    ...staticRouter,
    ...errorRouter
]

/**
 * 权限管理路由
 */
export const permessionRouter: Array<RouteRecordRaw> = [
    ...permession
];